- Static display
- good for publication
- effective to show very specific pattern
- Interactive display
- gives end user more flexibility
- exploratory visualization is convenient
Feb 13, 2019
R packages for this lectureinstall.packages(c("ggplot2","plotly", "DT", "gapminder"))
gapminder packagelibrary(gapminder) dat <- subset(gapminder, year==2007)
library(ggplot2) p <- ggplot(dat, aes(x = log(gdpPercap), y = lifeExp))+ geom_point(aes(size = sqrt(pop/pi)), pch = 21, show.legend = FALSE) + scale_size_continuous(range=c(1,30)) + aes(fill = continent) p
library(plotly) ggplotly(p + aes(label = country))
q <- ggplot(gapminder, aes(x = log(gdpPercap), y = lifeExp, frame=year))+ geom_point(aes(size = sqrt(pop/pi)), pch = 21, show.legend = FALSE) + scale_size_continuous(range=c(1,30)) + aes(fill = continent) ggplotly(q + aes(label = country))
library(DT) datatable(dat)
plot_ly(gapminder, x = ~gdpPercap, y = ~lifeExp, z = ~continent) %>% add_markers(color = ~continent)